package com.doge.controller.wx.promotion;

import com.doge.bean.base.BaseData;
import com.doge.bean.base.BaseParam;
import com.doge.bean.base.BaseRespVo;
import com.doge.bean.pojo.comment.Comment;
import com.doge.bean.vo.comment.CountVO;
import com.doge.service.wx.comment.WxCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 首页专题精选里面的评论板块
 */
@RestController
@RequestMapping("wx/comment")
public class WxCommentController {
    @Autowired
    WxCommentService wxCommentService;

    /**
     * wx/comment/list?valueId=264&type=1&showType=0 &page=1&limit=5
     * wx/comment/list?valueId=1116011&type=0&limit=20&page=1&showType=0
     * valueId可以有多个
     * type:type=0，则是商品评论；type=1，则是专题评论
     * showType: 是否显示图片,对应数据库里的has_picture
     * GET
     */
    @GetMapping("list")
    public BaseRespVo listComment(BaseParam baseParam,Integer valueId,Byte type,Integer showType){
        BaseData data = wxCommentService.listComment(baseParam,valueId,type,showType);
        return BaseRespVo.ok(data);
    }

    /**
     * /wx/comment/post   POST
     * 在专题精选里面发表留言 返回一个response json对象,request的时候 request Json 对象
     */
    @PostMapping("post")
    public BaseRespVo postComment(@RequestBody Comment comment){
        Comment postComment= wxCommentService.postComment(comment);
        return BaseRespVo.ok(postComment);
    }

    /**
     * wx/comment/count?valueId=268&type=0 GET
     * 搜索框里搜索“母亲节”，点击某个商品，查看全部里面
     */
    @GetMapping("count")
    public BaseRespVo count(Integer valueId,Byte type){
       CountVO countVO = wxCommentService.count(valueId,type);
       return BaseRespVo.ok(countVO);
    }

}